/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import { Col, Row } from 'antd';
import styles from './list.less';
const Index: React.FC<{
  title: string;
  options: any;
  data: Object;
}> = (props) => {
  const { title, options, data } = props;

  return (
    <div className={styles['list']}>
      <p className={styles['list--title']}>{title}</p>
      <div>
        {options.map(
          (item: { dataIndex?: string; renderText?: Function; title: string; hide: boolean }) => {
            const { dataIndex, renderText, title: ntitle, hide } = item;
            const fit1 = {
              xs: 24,
              md: 24,
              lg: 8,
              xl: 8,
              xxl: 8,
            };
            const fit = {
              xs: 24,
              md: 24,
              lg: 16,
              xl: 16,
              xxl: 16,
            };
            return (
              !hide && (
                <Row key={ntitle} className={styles['list--item']} justify='space-between'>
                  <Col {...fit1}>{ntitle}</Col>
                  <Col {...fit}>
                    {renderText
                      ? renderText(data, dataIndex ? data[dataIndex] : '')
                      : dataIndex && data[dataIndex]}
                  </Col>
                </Row>
              )
            );
          },
        )}
      </div>
    </div>
  );
};

export default Index;
